from itp.wp.models import *

# test the variance between rssi of each sample point

def RssiVariance():
	sp = SamplePointLoc.objects.filter(field_id = 0)
	rssill = []
	
	for _sp in sp:
		sr = SamplePointRssi.objects.filter(sample_point = _sp)
		rssil = []
		for _sr in sr:
			rssil.append(_sr.rssi)
		rssill.append(rssil)
	#print rssill
	
	Variancelist = []
	
	for r0 in rssill:
		Variance = []
		for r1 in rssill:
			v = 0
			#if r0 != r1:
			if True:
				i = 0
				while i < 4:
					v += (r0[i] - r1[i]) * (r0[i] - r1[i])
					i += 1
			Variance.append(v)
		Variance.sort()
		Variancelist.append(Variance)
	
	# print
	for v in Variancelist:
		print v